package canglang.monitor.cases.dao;

import canglang.monitor.cases.model.PublishAttachModel;
import canglang.monitor.cases.model.PublishUploadModel;
import canglang.monitor.core.base.dao.BaseDAO;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class CaseUploadDAO extends BaseDAO {
    public Integer uploadFeedbackAttach(PublishUploadModel publishUploadModel) {
        Map map = new HashMap();
        String sql = "addPublishAttach";
        map.put("deptId", publishUploadModel.getDeptId());
        map.put("uploadFileName", publishUploadModel.getUploadFileName());
        map.put("uploadCnt", publishUploadModel.getUploadCnt());
        map.put("createId", publishUploadModel.getCreateId());
        map.put("createDt", publishUploadModel.getCreateDt());
        map.put("updateId", publishUploadModel.getUpdateId());
        map.put("updateDt", publishUploadModel.getUpdateDt());
        return (Integer) getSqlMapClientTemplate().insert(sql, map);
    }

    public List getUploadList(int deptId){
        HashMap map = new HashMap();
        String sql = "getUploadList";
        if(deptId!=0){
            map.put("deptId", deptId);
        }
        return getSqlMapClientTemplate().queryForList(sql, map);
    }

    public PublishUploadModel getUploadAttach(int attachId){
        String sql = "getPublishAttach";
        Map map = new HashMap();
        map.put("attachId", attachId);
        return (PublishUploadModel) getSqlMapClientTemplate().queryForObject(sql, map);
    }

    public void deleteFeedbackAttach(int attachId){
        String sql = "deletePublishAttach";
        Map map = new HashMap();
        map.put("attachId", attachId);
        getSqlMapClientTemplate().delete(sql, map);
    }
}
